package CaseTraining;

import java.util.Scanner;

public class CaseDemo03 {
    public static void main(String[] args) {
        System.out.println("选手的最终得分为:" + score(6));
    }
    public static double score(int number){
        Scanner sc = new Scanner(System.in);
        int[] scores = new int[number];
        //遍历输入每一个人的分数
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请您输入第"+(i + 1)+"个评委的评分");
            int score = sc.nextInt();
            scores[i] = score;
        }
        //求出总分数、最高分和最低分
        int sum = 0;
        int max = scores[0];
        int min = scores[0];
        for (int i = 0; i < scores.length; i++) {
            //求和
            sum += scores[i];
            //求最大值
            if(max < scores[i]){
                max = scores[i];
            }
            //求最小值
            if(min > scores[i]){
                min = scores[i];
            }
        }
        System.out.println("选手的总得分是：" + sum);
        System.out.println("去掉一个最高分：" + max);
        System.out.println("去掉一个最低分：" + min);
        return 1.0*(sum - min - max) / (number - 2);
    }
}
